#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
	int n, m;
	cin >> n >> m;
	if(n == 1) {
		cout << 0 << endl;
		return 0;
	}
	cout << (n * (n - 1) / 2 - m) << endl;
	return 0;
}

